// applicationRepurchase.js
var api = require('../../utils/api.js')
var util = require('../../utils/util.js');
var md = require('../../utils/md5.js');
var app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    coupons_info:{}
  },

  /**
  * 生命周期函数--监听页面加载
  */
  onLoad: function (options) {
    var coupons_bag_id = options.id
    this.setData({
      coupons_bag_id: coupons_bag_id
    })
    this.couponsInfo();
  },

  //卡劵详情
  couponsInfo: function () {
    var that = this;
    api.POST({
      params: { id: that.data.coupons_bag_id },
      url: app.globalData.coupons_bag_info_url,
      success: function (res) {
        if (res.data.code == '') {
          that.setData({
            coupons_info: res.data.data
          })
        } else {
          if (res.data.message) {
            util.showError(res.data.message)
          } else {
            util.showError('出错了')
          }
        }
      },
      fail: function (fail) {
        util.showError("网络错误");
      }
    })
  },

  //联系客服
  connectService:function(e){
    wx.makePhoneCall({
      phoneNumber: app.globalData.servicePhone
    })
  }

})